//
//  LGPatientBreatheHeader.m
//  HeartDisease_YHJK
//
//  Created by 1234 on 2025/10/17.
//

#import "LGPatientBreatheHeader.h"

@interface LGPatientBreatheHeader()

/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *warnLabel;

@end

@implementation LGPatientBreatheHeader

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.titleLabel.text = LGNSString(dataDic[@"title"]);
    self.warnLabel.text = LGNSString(dataDic[@"warn"]);
    BOOL showUpload = [dataDic[@"is_upload"] integerValue]>0?YES:NO;
    BOOL showEva = [dataDic[@"is_eva"] integerValue]>0?YES:NO;
    self.uploadBtn.hidden = (showUpload == YES)?NO:YES;
    self.evaButton.hidden = (showEva == YES)?NO:YES;
    CGFloat evaRight = (showUpload == YES && showEva == YES) ? -viewPix(100) : -viewPix(12);
    [self.evaButton mas_updateConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(evaRight);
    }];
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self addSubview:self.titleLabel];
    [self addSubview:self.warnLabel];
    [self addSubview:self.uploadBtn];
    [self addSubview:self.evaButton];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(viewPix(13));
        make.left.equalTo(self).offset(viewPix(12));
    }];
    [self.warnLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_right).offset(viewPix(5));
        make.right.equalTo(self.evaButton.mas_left).offset(-viewPix(12));
        make.centerY.equalTo(self.titleLabel);
    }];
    [self.uploadBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-viewPix(12));
        make.centerY.equalTo(self.titleLabel);
        make.width.equalTo(@(viewPix(78)));
        make.height.equalTo(@(viewPix(24)));
    }];
    [self.evaButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-viewPix(12));
        make.centerY.equalTo(self.titleLabel);
        make.width.equalTo(@(viewPix(78)));
        make.height.equalTo(@(viewPix(24)));
    }];
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(18, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        [_titleLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    }
    return _titleLabel;
}

-(UILabel *)warnLabel{
    if(!_warnLabel){
        _warnLabel = [UILabel lableWithText:@"" colorString:@"#FF5F57" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _warnLabel;
}

-(UIButton *)uploadBtn{
    if(!_uploadBtn){
        _uploadBtn = [UIButton buttonWithTitle:@" 上传报告" titleFont:LGFont(12) textColor:@"#5E8EF5" imageName:@"患者档案-上传报告"];
        _uploadBtn.backgroundColor = [UIColor colorWithString:@"#F0F3FD"];
        [_uploadBtn addBorder:@"#5E8EF5" lineWidth:1 cornerRidus:2];
//        [_uploadBtn addTarget:self action:@selector(uploadBtnAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _uploadBtn;
}

-(UIButton *)evaButton{
    if(!_evaButton){
        _evaButton = [UIButton buttonWithTitle:@" 配置量表" titleFont:LGFont(13) textColor:@"#5E8EF5" imageName:@"患者档案-配置量表"];
        _evaButton.backgroundColor = [UIColor colorWithString:@"#F0F3FD"];
        [_evaButton addBorder:@"#5E8EF5" lineWidth:1 cornerRidus:2];
//        [_evaButton addTarget:self action:@selector(evaButtonAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _evaButton;
}



@end
